package domain;

public class Book implements IGeneralDomainObject {

	/*------------------------
	 * Book attributes
	 * ------------------------
	 */

	private int bookID, bookYear;
	private String bookName, bookAuthor, bookPublisher, bookLanguage, bookISBN;

	private String searchCondition;

	public Book() {
	}

	public Book(int bookYear, String bookName, String bookAuthor,
			String bookPublisher, String bookLanguage, String bookISBN) {
		super();
		this.bookYear = bookYear;
		this.bookName = bookName;
		this.bookAuthor = bookAuthor;
		this.bookPublisher = bookPublisher;
		this.bookLanguage = bookLanguage;
		this.bookISBN = bookISBN;
	}

	/*------------------------
	 * attributes getters&setters
	 * -----------------------
	 */
	public int getBookID() {
		return bookID;
	}

	public void setBookID(int bookID) {
		this.bookID = bookID;
	}

	public int getBookYear() {
		return bookYear;
	}

	public void setBookYear(int bookYear) {
		if (bookYear < -1)
			this.bookYear = 1;
		else
			this.bookYear = bookYear;
	}

	public String getBookName() {
		return bookName;
	}

	public void setBookName(String bookName) {
		this.bookName = bookName;
	}

	public String getBookAuthor() {
		return bookAuthor;
	}

	public void setBookAuthor(String bookAuthor) {
		this.bookAuthor = bookAuthor;
	}

	public String getBookPublisher() {
		return bookPublisher;
	}

	public void setBookPublisher(String bookPublisher) {
		this.bookPublisher = bookPublisher;
	}

	public String getBookLanguage() {
		return bookLanguage;
	}

	public void setBookLanguage(String bookLanguage) {
		this.bookLanguage = bookLanguage;
	}

	public String getBookISBN() {
		return bookISBN;
	}

	public void setBookISBN(String bookISBN) {
		this.bookISBN = bookISBN;
	}

	// -------------- END getters&setters ----------------- //

	/*
	 * -------------------------- IGeneralDomainObject implementation
	 * ---------------------------
	 */
	@Override
	public String getTableName() {
		return "TBook (bookName,bookAuthor,bookPublisher,bookLanguage,bookISBN,bookYear)";
	}

	@Override
	public String getUniqueCondition() {
		return "bookID=" + getBookID();
	}

	@Override
	public String getInsertValues() {
		return "'" + getBookName() + "','" + getBookAuthor() + "','"
				+ getBookPublisher() + "','" + getBookLanguage() + "','"
				+ getBookISBN() + "'," + getBookYear();
	}

	@Override
	public String[] getColumnsNames() {
		return new String[] { "bookID", "bookYear", "bookName", "bookAuthor",
				"bookPublisher", "bookLanguage", "bookISBN" };
	}

	@Override
	public String getSimpleTableName() {
		return "TBook";
	}

	@Override
	public String toString() {
		return getBookName();
	}

	@Override
	public String getFindValue() {
		return " bookYear=" + getBookYear() + " AND bookName='" + getBookName()
				+ "' AND bookAuthor='" + getBookAuthor()
				+ "' AND bookPublisher='" + getBookPublisher()
				+ "' AND bookLanguage='" + getBookLanguage()
				+ "' AND bookISBN='" + getBookISBN() + "'";
	}

	@Override
	public String getUpdateValue() {
		return "bookYear=" + getBookYear() + ",bookName='" + getBookName()
				+ "',bookAuthor='" + getBookAuthor() + "',bookPublisher='"
				+ getBookPublisher() + "',bookLanguage='" + getBookLanguage()
				+ "',bookISBN='" + getBookISBN() + "'";
	}

	@Override
	public String getDeleteValue() {
		return "";
	}

	@Override
	public String getDeleteCondition() {
		return "bookID=" + getBookID();
	}
}
